package com.itgt.classwork;

import java.util.Scanner;

public class Chapters4_2 {

	public static void main(String[] args) {
		int avg = 0;
		int sum = 0;
		Scanner scanner = new Scanner(System.in);
		System.out.println("学员数量：");
		int num = scanner.nextInt();
		//根据num确定数组元素个数
		int []score1 = new int[num];
		/*
		 * 	循环输入成绩
		 */
		for(int i=0;i<score1.length;i++) {
			System.out.println("第"+(i+1)+"个学生成绩");
			 score1[i] = scanner.nextInt();
			sum += score1[i];
		}
		int temp;
		/*
		 * 	冒泡排序
		 */
		for(int i=0;i<score1.length-1;i++) {
			for(int j=0;j<score1.length-1-i;j++) {
				if(score1[j]<score1[j+1]) {
					temp = score1[j];
					score1[j] = score1[j+1];
					score1[j+1] = temp;
				}
			}
		}
		avg = sum/score1.length;
		System.out.println("总成绩："+sum);
		System.out.println("平均值："+avg);
		/*
		 * 
		 * 	排序结果输出
		 */
		System.out.println("排序：由大到小");
		for(int i=0;i<score1.length;i++) {
			System.out.print(" "+score1[i]+" ");
		}
	}
}
